package connection;

/**
 * Created by IntelliJ IDEA.
 * User: Qiang
 * Date: 28.11.2008
 * Time: 00:09:17
 */
public class Querise {

    // SPARQLs search document meta-information with drug name
    public static String qMetaInfoNoAuthorPerDrug(String drugName) {
        String query = "PREFIX : <http://www.test.com/MedOnto.owl#> " +
                "PREFIX xsdt: <http://www.w3.org/2001/XMLSchema#> " +
                "SELECT DISTINCT ?Title ?Year ?City ?Publisher ?SourceType ?sourceURL " +
                "WHERE { " +
                "?Tag :hasTitle ?Title; " +
                     ":sourceURL ?sourceURL; " +
                     ":publishYear ?Year; " +
                     ":publishCity ?City; " +
                     ":publisherName ?Publisher; " +
                     ":sourceTypeValue ?SourceType. "+
                "?word :depictsSLE ?drug; " +
                      "a :Word; " +
                      ":content \""+drugName+"\"^^xsdt:string. " +
                "?Tag :contains ?sentence." +
                "?sentence :contains ?word. " +
                "}";
        return query;
    }

    // search document meta-information with two drug names
     public static String qMetaInfoNoAuthorPerDrugCombi(String drugName1, String drugName2) {
        String query = "PREFIX : <http://www.test.com/MedOnto.owl#> "+
                       "PREFIX xsdt: <http://www.w3.org/2001/XMLSchema#> "+
                       "SELECT DISTINCT ?Title ?Year ?City ?Publisher ?SourceType ?sourceURL " +
                       "WHERE { " +
                            "?doc :hasTitle ?Title; " +
                            ":sourceURL ?sourceURL; " +
                            ":publishYear ?Year; " +
                            ":publishCity ?City; "  +
                            ":publisherName ?Publisher; " +
                            ":sourceTypeValue ?SourceType. " +
                       "?drug1 a :Drug; " +
                            ":content \"" + drugName1 + "\"^^xsdt:string. " +
                       "?drug2 a :Drug; " +
                            ":content \"" + drugName2 +"\"^^xsdt:string." +
                       "?doc   :isAbout ?comparison. " +
                       "?comparison :hasPart ?drug1; " +
                                   ":hasPart ?drug2. " +
                       "}";
        return query;
    }

    // search author list with sourceURL
    public static String getAuthorsProDoc(String sourceURL) {
         String query = "PREFIX : <http://www.test.com/MedOnto.owl#> " +
                        "PREFIX xsdt: <http://www.w3.org/2001/XMLSchema#> " +
                        "SELECT DISTINCT ?First ?Last " +
                        "WHERE { ?b :sourceURL \""+sourceURL+"\"^^xsdt:string; " +
                        ":hasAuthor ?Author. " +
                        "?Author :authorFirstName ?First; " +
                        ":authorLastName ?Last; " +
                        "}";
        return query;
    }

    // search meth-information with publish year
    public static String getMetaInfoNoAuthorPerYear(String year) {
        String query =  "PREFIX : <http://www.test.com/MedOnto.owl#> " +
                        "PREFIX xsdt: <http://www.w3.org/2001/XMLSchema#> " +
                        "SELECT DISTINCT ?Title ?Year ?City ?Publisher ?SourceType ?sourceURL " +
                        "WHERE { ?b :hasTitle ?Title; " +
                        ":publishYear ?Year; " +
                        ":publishYear \""+year+"\"^^xsdt:string; " +
                        ":publishCity ?City; " +
                        ":publisherName ?Publisher; " +
                        ":sourceTypeValue ?SourceType; " +
                        ":sourceURL ?sourceURL. "+
                        "}";
        return query;
    }

}
